package com.manager.service;

import com.manager.dao.StudentDao;
import com.manager.domain.Student;
public class StudentService {
    /**
     * 学生管理
     */
    StudentDao studentDao = new StudentDao();
    public boolean addStudent(Student stu) {
        return studentDao.addStudent(stu);
    }

    public boolean isExists(String id) {
        Student[] stus = studentDao.findAllStudent();
        for (int i = 0; i < stus.length; i++) {
            Student stu = stus[i];
            if (stu!=null && stu.getId().equals(id)){
                return true;
            }
        }
        return false;
    }
    public void delStudent(String id) {
        studentDao.delStudent(id);
    }

    public void upDataStudent(Student student, String id) {
        studentDao.upDataStudent(student,id);
    }

    public Student[] findAllStudent() {
        Student[] allStudent = studentDao.findAllStudent();
        for (int i = 0; i < allStudent.length; i++) {
            Student student = allStudent[i];
            if (student!=null){
                return allStudent;
            }
        }
        return null;
    }
}
